import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        long ret = 0;
        for (int i = 0; i < n; i++) {
            int num = in.nextInt();

            if (num >= 1 && num <= 10) {
                continue;
            } else if (num > 10) {
                while (!(num >= 1 && num <= 10)) {
                    if (num % 10 == 0) {
                        num /= 10;
                        ret++;
                    } else {
                        int x = num % 10;
                        if (x <= 5) {
                            num -= x;
                            ret += x;
                        } else {
                            num += x;
                            ret += 10 - x;
                        }
                    }
                }
            } else {
                // 负数 或 0
                while (!(num >= 1 && num <= 10)) {
                    if (num >= -9 && num <= 0) {
                        ret += -num + 1;
                        num = 1;
                    } else if (num % 10 == 0) {
                        num /= 10;
                        ret++;
                    } else {
                        int x = num % 10;
                        num += -x;
                        ret += -x;
                    }
                }
            }
        }
        System.out.println(ret);
    }
}